﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;

namespace WfDesignBD
{
    class DemoToolboxService : ToolboxService
    {
        private ListBox toolBox;
        public ListBox ToolBox
        {
            get { return toolBox; }
            set { toolBox = value; }
        }

        #region implements ToolboxService

        protected override CategoryNameCollection CategoryNames
        {
            get { return null; }
        }

        protected override System.Collections.IList GetItemContainers(string categoryName)
        {
            ToolboxItem[] t = new ToolboxItem[this.toolBox.Items.Count];
            this.toolBox.Items.CopyTo(t, 0);
            return t;
        }

        protected override System.Collections.IList GetItemContainers()
        {
            ToolboxItem[] t = new ToolboxItem[this.toolBox.Items.Count];
            this.toolBox.Items.CopyTo(t, 0);
            return t;
        }

        protected override void Refresh()
        {
            throw new NotImplementedException();
        }

        protected override string SelectedCategory
        {
            get
            {
                return null;
            }
            set
            {
            }
        }

        protected override ToolboxItemContainer SelectedItemContainer
        {
            get
            {
                if (toolBox.SelectedIndex > 0)
                {
                    return new ToolboxItemContainer((ToolboxItem)toolBox.SelectedItem);
                }
                return null;
            }
            set
            {
                if (value == null)
                {
                    toolBox.SelectedIndex = -1;
                }
            }
        }

        #endregion
    }
}
